<?php

use yii\helpers\Url;
use yii\helpers\Html;
use website\helpers\Render;
use common\models\Cooperator;

$this->addCrumbs('资金管理');
$this->title = '充值';
?>

<div class="contenter">
    <?= $this->render('navigator', ['active' => 'recharge']) ?>
    
    <div id="user-contenter">
        <div class="box-shadow" id="sub-contenter">
            <div class="data-title"><span class="h3"><?= $this->title ?></span></div>
            <div class="data-content">
                <div class="data-mind">注意：已绑定的手机号/邮箱不仅可以用于账号直接登录，还可以提升账号安全性，建议<a class="cl-red" href="<?= Url::to('@web/designer/bind-email') ?>">验证邮箱</a></div>
                <form class="flyer-form mt-20px" id="flyer-create" action="<?= Url::to('@web/user/change-mobile') ?>" method="post">
                    <div class="form-item checker">
                        <div class="input-title">金额：</div>
                        <div class="input-inline"><input class="flyer-input" name="amount" type="text"></div>
                    </div>
                    <div class="form-item checker">
                        <div class="input-title">备注：</div>
                        <div class="input-inline"><input class="flyer-input" name="remark" type="text" value="<?= $remark ?>" disabled></div>
                    </div>
                    <div class="form-item checker">
                        <div class="input-title"></div>
                        <div class="input-inline"><button class="flyer-button normal border-round" id="save-button" type="submit">保 存</button></div>
                    </div>
                    <textarea id="flyer-create-json" data-form="#flyer-create" style="display:none;"><?= $relate ?></textarea>
                    <input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken() ?>">
                </form>
            </div>
        </div>
    </div>
</div>

<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tableHandler.class.js') ?>"></script>
<script>
    $(document).ready(function() {
        // 表单数据验证
        (new checker).init({ruleDom: '#flyer-create-json'});

        // 发送验证码操作
        tableHandler.requestSingle({
            button: '#get-captcha', isConfirm: false, isShadow: false,
            url: "<?= Url::to('@web/user/captcha-mobile') ?>",
            beforeRequest: function(param) {
                param.data = { type: 'change-mobile' };
                $('#get-captcha').attr('disabled', true);
            },
            requestFail: function(param) {
                $('#get-captcha').removeAttr('disabled');
            },
            requestSuccess: function (param) {
                var seconds = 60;
                var timer = setInterval(function() {
                    if(--seconds > 0) {
                        $('#get-captcha').text(seconds + '秒后重试');
                    }
                    else {
                        $('#get-captcha').text('重新发送');
                        $('#get-captcha').removeAttr('disabled');
                        clearInterval(timer);
                    }
                }, 1000);
            }
        });
    });
</script>